package dao.impl;

import java.sql.SQLException;
import java.util.List;

import com.ibatis.sqlmap.client.SqlMapClient;

import module.KPI;
import dao.ABSBasicDAO;
import domain.vo.KPIQueryObject;
import domain.vo.queryObject;

/**
/**
* @ClassName: KPIDAOImpl
* @Description: KPIDAOImpl
* @author chenchao
* @date 2013-12-12 上午07:39:38
*
 */
public class KPIDAOImpl  extends ABSBasicDAO<KPI>{
	
	/**
	 * 构造函数
	 * @param sqlMapClient
	 */
	public KPIDAOImpl(SqlMapClient sqlMapClient) {
		super(sqlMapClient);
	}

	/* (non-Javadoc)
	 * @see dao.ABSBasicDAO#insertT(java.lang.Object)
	 */
	@Override
	public void insertT(KPI t) throws SQLException {
		// TODO Auto-generated method stub
		sqlMapClient.insert("KPI.insertKPIInfo", t);
	}

	/* (non-Javadoc)
	 * @see dao.ABSBasicDAO#getObjectByQueryObject(domain.vo.queryObject)
	 */
	@Override
	public List<KPI> getObjectByQueryObject(queryObject queryObject)
			throws SQLException {	
		KPIQueryObject kipQO = (KPIQueryObject) queryObject;
		if(kipQO.getClazz().equals("month")){
			return sqlMapClient.queryForList("KPI.getObjectByQueryObject", queryObject);
		} else {
			return sqlMapClient.queryForList("KPI.getQuarterObjectByQueryObject", queryObject);
		}
	}

	/* (non-Javadoc)
	 * @see dao.ABSBasicDAO#countByQueryObject(domain.vo.queryObject)
	 */
	@Override
	public int countByQueryObject(queryObject queryObject) throws SQLException {
		// TODO Auto-generated method stub
		return (Integer)sqlMapClient.queryForObject("KPI.countByQueryObject",queryObject);
	}

}
